package com.lp.rpc.server;

import com.lp.rpc.domain.LpRequest;
import com.lp.rpc.utils.LpStringUtil;
import io.netty.util.internal.StringUtil;
import org.reflections.Reflections;

import java.lang.reflect.Method;
import java.util.Set;

/**
 * 服务反射调用
 *
 * @author steakLiu
 */
public class LpServerCall {

    public static Object serviceCall(LpRequest lpRequest){

        Object result = null;
        try {
            Object instance = Class.forName(lpRequest.getClassName()).newInstance();
            Method method = instance.getClass().getMethod(lpRequest.getMethodName(), lpRequest.getParamTypes());
            result = method.invoke(instance, lpRequest.getParams());
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
}
